<%@page contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<link href="resources/ztree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet"
      type="text/css" />
<script src="resources/ztree/js/jquery.ztree.all-3.5.min.js"
        type="text/javascript"></script>
<script src="resources/jquery.json-2.3.js" type="text/javascript"></script>
<script type="text/javascript">
    var setting = {
        callback: {
            onNodeCreated: zTreeOnNodeCreated
        },
        data : {
            simpleData : {
                idKey : "id",
                pIdKey : "pid",
                enable : true
            }
        }
    };

    function zTreeOnNodeCreated(event, treeId, treeNode) {
        //如果不是叶子节点
        //if(!treeNode.isParent){
         $("#"+treeNode.tId+"_a").attr("rel","jbsxBox").attr("target","ajax").attr("href","category/tab/"+treeNode.id) ;
       // }
    }

    function loadMenuTree() {
        $.ajax({
            async : false,
            cache : false,
            type : 'POST',
            dataType : "json",
            url : "${ctx}/category/dotree",//请求的action路径
            error : function() {//请求失败处理函数
                alert('请求失败');
            },
            success : function(data) { //请求成功后处理函数。
                var treeObj = $.fn.zTree.init($("#rolemenutree"), setting, data);
                treeObj.expandAll(true);
            }
        });

    }

    $(document).ready(function() {
        loadMenuTree();
    });
</script>

<div class="pageContent" style="padding:5px">
    <div class="tabs">
        <div class="tabsHeader">
            <div class="tabsHeaderContent">
                <ul>
                    <li><a href="javascript:;"><span>产品类别管理</span></a></li>
                </ul>
            </div>
        </div>
        <div class="tabsContent">
            <div>
                <div layoutH="55" style="float:left; display:block; overflow:auto; width:240px; border:solid 1px #CCC; line-height:21px; background:#fff">
                    <ul id="rolemenutree" class="ztree"></ul>
                </div>
                <div id="jbsxBox" class="unitBox" style="margin-left:246px;">
                    <!--#include virtual="list1.html" -->
                </div>
            </div>
        </div>
        <div class="tabsFooter">
            <div class="tabsFooterContent"></div>
        </div>
    </div>
</div>

